/*
 * main.cpp
 *
 *  Created on: 15.03.2013
 *      Author: valya
 */
#include <vector>
#include <iostream>
#include <fstream>
#include "my_search.h"

int main()
{
	//std::ifstream in("in.txt");
	//std::ofstream out("out.txt");
	std::istream & in = std::cin;
	std::ostream & out = std::cout;
	int n;
	in >> n;
	std::vector<point_t> points;
	for (int i = 0; i < n; i++)
	{
		double x, y;
		in >> x >> y;
		points.push_back(point_t(x,y));
	}

	int m;
	in >> m;
	if (n == 0)
	{
		for (int i = 0; i < m; i++)
			out << 0 << '\n';
		return 0;
	}
	tree_t tree(points);
	for (int i = 0; i < m; i++)
	{
		double lx, ly, rx, ry;
		in >> lx >> ly >> rx >> ry;
		rect_t rect = rect_t(point_t(lx, ly), point_t(rx, ry));
		std::vector<point_t> ans = tree.search_in_rect(rect);
		out << ans.size() << '\n';
		out.precision(30);
		for (auto i = ans.begin(); i < ans.end(); i++)
		{
			out << (*i).x << " " << (*i).y << '\n';
		}
	}
}
